#include <iostream>
#include <vector>
#include <string>
#include <unordered_map>
using namespace std;

class Solution
{
public:
    int maximumCostSubstring(string s, string chars, vector<int> &vals)
    {
        unordered_map<char, int> m;
        for (char c = 'a'; c <= 'z'; c++)
            m[c] = c - 'a' + 1;
        for (int i = 0; i < chars.size(); i++)
            m[chars[i]] = vals[i];
        vector<int> dp(s.size() + 1, 0);
        for (int i = 0; i < s.size(); i++)
        {
            dp[i+1] = max(dp[i] + m[s[i]], m[s[i]]);
        }
        return *max_element(dp.begin(), dp.end());
    }
};

int main()
{
    cout << "Code2606" << endl;
    Solution s;
    return 0;
}